#import "GLPlane.h"

#import "OpenGLplane.c"

@implementation GLPlane	

- (id)initWithFrame:(NSRect)frameRect
{
    self = [super initWithFrame:frameRect];
    if (self) {
        _view = [[NSOpenGLView alloc] initWithFrame:frameRect];
        [self addSubview:_view];
    }
    
    return self;
}

- (NSTimeInterval)animationTimeInterval
{
    return 0.01;
}

- (void)setFrameSize:(NSSize)newSize
{
    [super setFrameSize:newSize];
    [_view setFrameSize:newSize];
    _initedGL = NO;

}

- (void)drawRect:(NSRect)rects
{
    
    [_view lockFocus];
    
    if (!_initedGL) {
        init_plane();
        draw_plane();

        _initedGL = YES;
    }

    [_view unlockFocus];
}


- (void)oneStep
{
    [_view lockFocus];
    animate_plane();
    [_view unlockFocus];

    
    return;
}


- (BOOL)hasConfigureSheet { return NO; }
- (NSWindow*)configureSheet { return nil; }

@end
